var e = require("../../@babel/runtime/helpers/createForOfIteratorHelper"),
  t = require("../../utils/http.js"),
  a = require("../../utils/api.js"),
  r = require("../../utils/language/switchLanguage.js");
Page({
  data: { list: [], chooseId: [], chooseData: {} },
  onLoad: function (e) {
    this.initLanguage(),
      this.setData({ orderNo: e.orderNo }),
      this.getOrderDetail({ orderSn: e.orderNo });
  },
  initLanguage: function () {
    var e = r.languageVersion(wx.getStorageSync("language"));
    this.setData({ _t: e, languageType: wx.getStorageSync("language") }),
      wx.setNavigationBarTitle({ title: e["取消订单"] });
  },
  getOrderDetail: function (a) {
    var r = this;
    t.getOrderDetail(a).then(function (t) {
      var a = t.data.orderDetailInfoVOList;
      console.log(a, "orderDetailInfoVOList");
      var s,
        o = [],
        n = e(a);
      try {
        for (n.s(); !(s = n.n()).done; ) {
          var i = s.value;
          if (2 == i.ticketClassify && 1 == i.museumOrderUserVOS[0].status)
            o.push(i.museumOrderUserVOS[0]);
          else {
            var l,
              d = e(i.museumOrderUserVOS);
            try {
              for (d.s(); !(l = d.n()).done; ) {
                var u = l.value;
                (1 != u.status && 12 != u.status) || o.push(u);
              }
            } catch (e) {
              d.e(e);
            } finally {
              d.f();
            }
          }
        }
      } catch (e) {
        n.e(e);
      } finally {
        n.f();
      }
      console.log(a, "list"), r.setData({ list: a, listData: o });
    });
  },
  changeOrder: function (e) {
    var t = {},
      a = e.detail.value;
    if (a.length > 0) for (var r = 0; r < a.length; r++) t[a[r]] = !0;
    else t = {};
    this.setData({ chooseId: a, chooseData: t });
  },
  checkAll: function () {
    var t = this.data.list,
      a = this.data.listData,
      r = this.data.chooseData,
      s = this.data.chooseId;
    if (a.length == s.length) this.setData({ chooseData: {}, chooseId: [] });
    else {
      (s = []), (r = {});
      var o,
        n = e(t);
      try {
        for (n.s(); !(o = n.n()).done; ) {
          var i = o.value;
          if (1 == i.status || 12 == i.status)
            if (2 == i.ticketClassify)
              1 == i.museumOrderUserVOS[0].status &&
                ((r[i.museumOrderUserVOS[0].id] = !0),
                s.push(i.museumOrderUserVOS[0].id));
            else {
              var l,
                d = e(i.museumOrderUserVOS);
              try {
                for (d.s(); !(l = d.n()).done; ) {
                  var u = l.value;
                  (r[u.id] = !0), s.push(u.id);
                }
              } catch (e) {
                d.e(e);
              } finally {
                d.f();
              }
            }
        }
      } catch (e) {
        n.e(e);
      } finally {
        n.f();
      }
      this.setData({ chooseData: r, chooseId: s });
    }
  },
  confirm: function () {
    var e = this;
    0 != e.data.chooseId.length
      ? wx.showModal({
          title: this.data._t["提示"],
          content: this.data._t["确认要取消选中的订单吗？"],
          confirmText: e.data._t["确定"],
          cancelText: e.data._t["取消"],
          success: function (a) {
            if (a.confirm) {
              wx.showLoading({ title: e.data._t["取消中"] + "..." });
              var r = {
                orderSn: e.data.orderNo,
                merchantNo: wx.getStorageSync("merchantNo"),
                orderUserId: e.data.chooseId,
              };
              t.CancelOrder(r).then(function (t) {
                var a = getCurrentPages(),
                  r = a[a.length - 2];
                console.log(r, "prevPage"),
                  r.getOrderDetail &&
                    setTimeout(function () {
                      wx.hideLoading(),
                        r.getOrderDetail({ orderSn: e.data.orderNo }),
                        wx.setStorageSync("isRefresh", !0),
                        wx.navigateBack();
                    }, 2e3);
              });
            }
          },
        })
      : a.showMsg(this.data._t["请先选择需要取消的人员"]);
  },
  onReady: function () {},
  onShow: function () {},
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {},
  onReachBottom: function () {},
});
